﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Iesi.Collections;
using Iesi.Collections.Generic;


namespace XWord.Fundamental.Domain
{
    /// <summary>
    /// 词根
    /// </summary>
    public class Etyma:Entity
    {
        public virtual string Comment { get; set; }
        /// <summary>
        /// 分类
        /// </summary>
        public virtual Category Category { get; set; }

        public virtual ISet Words { get; set; }

        public virtual IList<string> Comments { get; set; }

        //public virtual string EtymaType
        //{
        //    get
        //    {
        //        return typeof(Etymon).ToString();
        //    }
        //}
    }

    /// <summary>
    /// 词根
    /// </summary>
    public class Etymon : Etyma
    {
        //public virtual string EtymaType
        //{
        //    get
        //    {
        //        return this.ToString();
        //    }
        //}

        public virtual Etymon Parent { get; set; }

        private Iesi.Collections.Generic.ISet<Etymon> _children = new Iesi.Collections.Generic.HashedSet<Etymon>();

        public virtual Iesi.Collections.Generic.ISet<Etymon> Children
        {
            get { return _children; }
            set { _children = value as Iesi.Collections.Generic.ISet<Etymon>; }
        }

        //public virtual Guid ParentId { get; set; }

        /// <summary>
        /// 等级
        /// </summary>
        public virtual EtymsTypeLevel Level { get; set; }
    }

    /// <summary>
    /// 前缀
    /// </summary>
    public class PreFix : Etyma
    {
        //public override string EtymaType
        //{
        //    get
        //    {
        //        return this.ToString();
        //    }
        //}
    }

    /// <summary>
    /// 后缀
    /// </summary>
    public class Suffix : Etyma
    {
        //public override string EtymaType
        //{
        //    get
        //    {
        //        return this.ToString();
        //    }
        //}
    }

    [Serializable]
    [Flags]
    public enum EtymaType
    {
        None=0x00,
        /// <summary>
        /// 前缀
        /// </summary>
        PreFix=0x01,
        /// <summary>
        /// 词根
        /// </summary>
        Etymon = 0x02,
        /// <summary>
        /// 后缀
        /// </summary>
        Suffix = 0x03
    }

    public enum EtymsTypeLevel
    {
        Junior,
        Middle,
        Advanced,
        Custom
    }

    /// <summary>
    /// 词根含义
    /// </summary>
    public class EtymaComment : Entity
    {

        public Iesi.Collections.Generic.ISet<Word> Words { get; set; }
    }
}
